home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_6 / SBUS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  4KB  |  111 lines

  1. /* $Id: sbus.h,v 1.16 1998/12/16 04:33:52 davem Exp $
  2.  * sbus.h:  Defines for the Sun SBus.
  3.  *
  4.  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5.  */
  6.  
  7. #ifndef _SPARC_SBUS_H
  8. #define _SPARC_SBUS_H
  9.  
  10. #include <asm/oplib.h>
  11. #include <asm/iommu.h>
  12.  
  13. /* We scan which devices are on the SBus using the PROM node device
  14.  * tree.  SBus devices are described in two different ways.  You can
  15.  * either get an absolute address at which to access the device, or
  16.  * you can get a SBus 'slot' number and an offset within that slot.
  17.  */
  18.  
  19. /* The base address at which to calculate device OBIO addresses. */
  20. #define SUN_SBUS_BVADDR        0xf8000000
  21. #define SBUS_OFF_MASK          0x01ffffff
  22.  
  23. /* These routines are used to calculate device address from slot
  24.  * numbers + offsets, and vice versa.
  25.  */
  26.  
  27. extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
  28. {
  29.   return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
  30. }
  31.  
  32. extern __inline__ int sbus_dev_slot(unsigned long dev_addr)
  33. {
  34.   return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
  35. }
  36.  
  37. extern __inline__ unsigned long sbus_dev_offset(unsigned long dev_addr)
  38. {
  39.   return (unsigned long) (((dev_addr)-SUN_SBUS_BVADDR)&SBUS_OFF_MASK);
  40. }
  41.  
  42. struct linux_sbus;
  43.  
  44. /* Linux SBUS device tables */
  45. struct linux_sbus_device {
  46.   struct linux_sbus_device *next;      /* next device on this SBus or null */
  47.   struct linux_sbus_device *child;     /* For ledma and espdma on sun4m */
  48.   struct linux_sbus *my_bus;           /* Back ptr to sbus */
  49.   int prom_node;                       /* PROM device tree node for this device */
  50.   char prom_name[32];                  /* PROM device name */
  51.  
  52.   struct linux_prom_registers reg_addrs[PROMREG_MAX];
  53.   int num_registers, ranges_applied;
  54.  
  55.   unsigned int irqs[4];
  56.   int num_irqs;
  57.  
  58.   unsigned long sbus_addr;             /* Absolute base address for device. */
  59.   unsigned long sbus_vaddrs[PROMVADDR_MAX];
  60.   unsigned long num_vaddrs;
  61.   unsigned long offset;                /* Offset given by PROM */
  62.   int slot;
  63. };
  64.  
  65. /* This struct describes the SBus(s) found on this machine. */
  66. struct linux_sbus {
  67.     struct linux_sbus *next;             /* next SBus, if more than one SBus */
  68.     struct linux_sbus_device *devices;   /* Link to devices on this SBus */
  69.     struct iommu_struct *iommu;          /* IOMMU for this sbus if applicable */
  70.     int prom_node;                       /* PROM device tree node for this SBus */
  71.     char prom_name[16];                  /* Usually "sbus" or "sbi" */
  72.     int clock_freq;
  73.     struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
  74.     int num_sbus_ranges;
  75.     int devid;
  76.     int board;
  77. };
  78.  
  79. extern struct linux_sbus *SBus_chain;
  80.  
  81. extern __inline__ int
  82. sbus_is_slave(struct linux_sbus_device *dev)
  83. {
  84.     /* Have to write this for sun4c's */
  85.     return 0;
  86. }
  87.  
  88. /* Device probing routines could find these handy */
  89. #define for_each_sbus(bus) \
  90.         for((bus) = SBus_chain; (bus); (bus)=(bus)->next)
  91.  
  92. #define for_each_sbusdev(device, bus) \
  93.         for((device) = (bus)->devices; (device); (device)=(device)->next)
  94.         
  95. #define for_all_sbusdev(device, bus) \
  96.     for((bus) = SBus_chain, (device) = (bus)->devices; (bus); (device)=((device)->next ? (device)->next : ((bus) = (bus)->next, (bus) ? (bus)->devices : 0)))
  97.  
  98. /* If you did not get the buffer from mmu_get_*() or sparc_alloc_dvma()
  99.  * then you must use this to get the 32-bit SBUS dvma address.
  100.  * And in this case it is your responsibility to make sure the buffer
  101.  * is GFP_DMA, ie. that it is not greater than MAX_DMA_ADDRESS.
  102.  */
  103. #define sbus_dvma_addr(__addr)    ((__u32)(__addr))
  104.  
  105. /* Apply promlib probed SBUS ranges to registers. */
  106. extern void prom_apply_sbus_ranges(struct linux_sbus *sbus, 
  107.                    struct linux_prom_registers *sbusregs,
  108.                    int nregs, struct linux_sbus_device *sdev);
  109.  
  110. #endif /* !(_SPARC_SBUS_H) */
  111.